package 
{
	import com.engine.core.controls.system.wealth.SWF_Parser;
	import com.engine.core.model.customize.Bitmap;
	import com.engine.core.view.resource.chat.ResourceLib;
	import com.ming.ui.controls.Button;
	import com.ming.ui.controls.core.UIComponent;
	import com.ming.ui.skins.ButtonSkin;
	import com.ming.ui.skins.CheckBoxSkin;
	import com.ming.ui.skins.ListSkin;
	import com.ming.ui.skins.NumericStepperSkin;
	import com.ming.ui.skins.PanelSkin;
	import com.ming.ui.skins.ScrollBarSkin;
	import com.ming.ui.skins.Skin;
	import com.ming.ui.skins.SliderSkin;
	import com.ming.ui.skins.TabBarSkin;
	import com.ming.ui.skins.ToolTipSkin;
	import com.ming.ui.style.BitmapDataPool;
	import com.ming.ui.style.IStyle;
	import com.ming.ui.style.StyleManager;
	
	import flash.display.BitmapData;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.filters.ColorMatrixFilter;
	import flash.filters.GlowFilter;
	import flash.geom.Rectangle;
	import flash.text.TextFormat;
	

	/**
	 * 所有样式在此定义
	 */ 
	public class Style implements IStyle
	{
	
		private static var pool:BitmapDataPool;
			
		private static var instance:Style;
		
		public static function getInstance():Style{
			if(instance == null){
				instance = new Style();
			}
			return instance;
		}
		
		public static function get textFormat():TextFormat{
			return new TextFormat("宋体",12,0xffffff);
		}
		
		public static function get whiteTextFormat():TextFormat{
			return new TextFormat("宋体",12,0x000000);
		}
		
		public static function get textWriteFilter():Array
		{
			var filtersArr:Array = new Array();
			filtersArr.push(new GlowFilter(0xffffff,1,3,3));
			return filtersArr;
		}
		public static function get colorMatrixFilter():Array
		{
			var filtersArr:Array = new Array();
			filtersArr.push(new ColorMatrixFilter([
				0.3086, 0.6094, 0.0820, 0, 0,
				0.3086, 0.6094, 0.0820, 0, 0,
				0.3086, 0.6094, 0.0820, 0, 0,
				0,      0,      0,      1, 0
			]));
			return filtersArr; 
		}
		public static function get textBlackFilter():Array
		{
			var filtersArr:Array = new Array();
			filtersArr.push(new GlowFilter(0x000000,1,3,3,6));
			return filtersArr;
		}
		
		/**
		 * 启动样式管理，并且启动位图缓存池(位图缓存池默认只管理默认样式) 
		 * 
		 */		
		public function startInit():void{
			
			ResourceLib.getInstance().setLoadspeaker(Style.getClass(LoadResource.VIEWUI_URL,"loudspeaker"));
			ResourceLib.getInstance().captainFlag=Style.getUIBitmapData(LoadResource.MAIN_URL,"Captain");
		}
		
		public function preInit():void{
			StyleManager.getInstance().setUpStyle(this);
			pool = BitmapDataPool.getInstance();
			ToolTipSkin.bgSkin = tipSkin;
			ToolTipSkin.tf = textFormat;
		}
		
		/**
		 * 通过名称和url获取对应Class 
		 */		
		public static function getClass(url:String,name:String):Class{
			try{
			return SWF_Parser.getInstance().getClass(url,name);
			}catch(e:Error){
				return null
			}
			return null;
		}
		/**
		 *  通过名称和url获取对应元件或者sprite
		 * @param url
		 * @param name
		 * @return 
		 * 
		 */		
		public static function getSprite(url:String,name:String):Sprite{
			var clazz:Class = getClass(url,name);
			var bg:MovieClip
			if(clazz){
				bg= new clazz();
				bg.stop();
				bg.cacheAsBitmap = true;
			}
			return bg;
		}
		/**
		 * 通过名称获取视图对象
		 * 
		 */	
		public static function getViewBg(name:String,url:String=""):Sprite{
			if(url=="")
				url =LoadResource.VIEWUI_URL;
			return getSprite(url,name);
		}
		/**
		 * 指定名称和URL获取位图数据
		 */		
		public static function getUIBitmapData(url:String,name:String):BitmapData{
			if(name == null || url == null)
				return null;
			var bitmapdata:BitmapData = pool.getBitmapData(name,url);
			if(bitmapdata == null){
				var clazz:Class = SWF_Parser.getInstance().getClass(url,name);
				if(clazz){
					bitmapdata = new clazz(0,0);
					pool.addBitmapData(name,url,bitmapdata);
				}
			}
			return bitmapdata;
		}
		public static function getUIBitmap(url:String,name:String):Bitmap{			 
			var bitmap:Bitmap = new Bitmap(getUIBitmapData(url,name));
			return bitmap;
		}
		
		public static function getFriendSkin(name:String, rect:Rectangle = null):Skin
		{
			return getSkin( name, LoadResource.FRIENDUI_URL, rect);
		}
		
		public static function getFriendButtonSkin(normal:String, over:String, down:String, disable:String = null, rect:Rectangle = null):ButtonSkin
		{
			var buttonSkin:ButtonSkin = new ButtonSkin();
			buttonSkin.skin = getUIBitmapData(LoadResource.UI_URL,normal);
			buttonSkin.overSkin = getUIBitmapData(LoadResource.UI_URL,over);
			buttonSkin.downSkin = getUIBitmapData(LoadResource.UI_URL,down);
			buttonSkin.disableSkin = getUIBitmapData(LoadResource.UI_URL,disable);
			buttonSkin.rect = rect;
			return buttonSkin;
		}
		
//		public static function getFriendTabBarSkin():TabBarSkin
//		{
//			var tabSkin:TabBarSkin = new TabBarSkin();
//			tabSkin.tabBtnFunc = friendTabBarSkin;
//			tabSkin.soundFunc = playTabBarSound;
//			return tabSkin;
//		}
//		
//		private static function friendTabBarSkin():ButtonSkin
//		{
//			var tabBtnSkin:ButtonSkin = getFriendButtonSkin("LtabSkin","Ltab_overSkin","Ltab_selectedSkin",null,new Rectangle(4,5,18,35));
//			tabBtnSkin.selectedSkin = getUIBitmapData(LoadResource.UI_URL,"Ltab_selectedSkin"); 
//			return tabBtnSkin;
//		}
		
//		public static function getListTabBarSkin():TabBarSkin
//		{
//			var tabSkin:TabBarSkin = new TabBarSkin();
//			tabSkin.tabBtnFunc = listTabBarSkin;
//			tabSkin.soundFunc = playTabBarSound;
//			return tabSkin;
//		}
//		
//		private static function listTabBarSkin():ButtonSkin
//		{
//			var tabBtnSkin:ButtonSkin = getFriendButtonSkin("tabListSkin","tabListOverSkin","tabListDownSkin",null,new Rectangle(3,3,71,17));
//			tabBtnSkin.selectedSkin = getUIBitmapData(LoadResource.UI_URL,"tabListDownSkin"); 
//			return tabBtnSkin;
//		}
		/**
		 * 供外部调用创建按钮皮肤的方法 
		 * @param normal
		 * @param over
		 * @param down
		 * @param disable
		 * @param rect
		 * @param url
		 * 
		 */		
		public static function getButtonSkin(normal:String,over:String,down:String,disable:String,url:String,rect:Rectangle=null):ButtonSkin{
			var buttonSkin:ButtonSkin = new ButtonSkin();
			buttonSkin.skin = getUIBitmapData(url,normal);
			buttonSkin.overSkin = getUIBitmapData(url,over);
			buttonSkin.downSkin = getUIBitmapData(url,down);
			buttonSkin.disableSkin = getUIBitmapData(url,disable);
			buttonSkin.rect = rect;
			return buttonSkin;
		}
		/**
		 * 供外部使用获取普通皮肤的方法
		 * @param name
		 * @param url
		 * @param rect
		 * @return 
		 * 
		 */		
		public static function getSkin(name:String,url:String,rect:Rectangle=null):Skin{
			var skin:Skin = new Skin(getUIBitmapData(url,name),rect);
			return skin;
		}
		/**
		 * 处理默认样式的方法
		 */
		private function createButtonSkin(normal:String,over:String,down:String,disable:String,rect:Rectangle=null):ButtonSkin{
			var buttonSkin:ButtonSkin = new ButtonSkin();
			buttonSkin.skin = getUIBitmapData(LoadResource.UI_URL,normal);
			buttonSkin.overSkin = getUIBitmapData(LoadResource.UI_URL,over);
			buttonSkin.downSkin = getUIBitmapData(LoadResource.UI_URL,down);
			buttonSkin.disableSkin = getUIBitmapData(LoadResource.UI_URL,disable);
			buttonSkin.rect = rect;
			return buttonSkin;
		}
		/**
		 * 处理默认样式的方法
		 */
		private function createSkin(name:String,rect:Rectangle=null):Skin{
			var skin:Skin = new Skin(getUIBitmapData(LoadResource.UI_URL,name),rect);
			return skin;
		}
		
		private function createSkinViewUI(name:String,rect:Rectangle=null,url:String=""):Skin{
			if(url=="")
				url = LoadResource.VIEWUI_URL;
			var skin:Skin = new Skin(getUIBitmapData(url,name),rect);
			return skin;
		}
		
		public function get textFormat():TextFormat{
			return new TextFormat("Tahoma",12,0xffffff); 
		}
		
		public function get buttonSkin():Skin{
			var buttonSkin:ButtonSkin = createButtonSkin("button_skin","button_overSkin","button_downSkin","button_downSkin",new Rectangle(16,5,42,19))
			buttonSkin.soundFunc = playButtonSound;
			return buttonSkin;
		}
		
		/**
		 *帮会战战况统计按钮皮肤 
		 * @return 
		 * 
		 */		
		public function CityFightInfoSkin():Skin
		{
			
			//var buttonSkin:ButtonSkin = createButtonSkin("cityFight_upSkin","cityFight_overSkin","cityFight_downSkin","button_downSkin",null);
			var buttonSkin:ButtonSkin = getButtonSkin("cityFight_upSkin","cityFight_overSkin","cityFight_downSkin","cityFight_downSkin",LoadResource.VIEWUI_URL);
			buttonSkin.soundFunc = playButtonSound;
			return buttonSkin;
		}
		
		public function get selectedSkin():Skin{
			var selectedSkin:ButtonSkin = buttonSkin as ButtonSkin;
//			selectedSkin.selectedSkin = getUIBitmapData(LoadResource.UI_URL,"deep_downSkin");
			return selectedSkin;
		}
		
		public function get checkBoxSkin():CheckBoxSkin
		{
			var boxSkin:CheckBoxSkin = new CheckBoxSkin();
			var selected:Skin = createButtonSkin("checkbox_selectedSkin","checkbox_selectedSkin","checkbox_selectedSkin","");
			var unselect:Skin = createButtonSkin("checkbox_skin","checkbox_overSkin","checkbox_overSkin","");
			boxSkin.selectedSkin = selected;
			boxSkin.unSelectedSkin = unselect;
			return boxSkin;
		}
		
		public function get soundCtrlSkin():CheckBoxSkin
		{
			var boxSkin:CheckBoxSkin = new CheckBoxSkin();
			var selected:Skin = createBtnSkin("toolbar_laba2","toolbar_laba2","toolbar_laba2","");
			var unselect:Skin = createBtnSkin("toolbar_laba1","toolbar_laba1","toolbar_laba1","");
			boxSkin.selectedSkin = selected;
			boxSkin.unSelectedSkin = unselect;
			return boxSkin;
			
			function createBtnSkin(normal:String,over:String,down:String,disable:String,rect:Rectangle=null):ButtonSkin{
				var buttonSkin:ButtonSkin = new ButtonSkin();
				buttonSkin.skin = getUIBitmapData(LoadResource.MAIN_URL,normal);
				buttonSkin.overSkin = getUIBitmapData(LoadResource.MAIN_URL,over);
				buttonSkin.downSkin = getUIBitmapData(LoadResource.MAIN_URL,down);
				buttonSkin.disableSkin = getUIBitmapData(LoadResource.MAIN_URL,disable);
				buttonSkin.rect = rect;
				return buttonSkin;
			}
		}
		
		public function get npcCloseBtnSkin():Skin
		{
			return createButtonSkin("npc_close","npc_closeOver","npc_closeDown",'');
		}
		
		public function get radioButtonSkin():CheckBoxSkin
		{
			var boxSkin:CheckBoxSkin = new CheckBoxSkin();
			var selected:Skin = createButtonSkin("radio_selectedSkin","radio_selectedSkin","radio_selectedSkin","");
			var unselect:Skin = createButtonSkin("radio_skin","radio_overSkin","radio_overSkin","");
			boxSkin.selectedSkin = selected;
			boxSkin.unSelectedSkin = unselect;
			return boxSkin;
		}
		
		public function get scrollBarSkin():ScrollBarSkin{
			var scrollBar:ScrollBarSkin = new ScrollBarSkin();
			scrollBar.width = 16;
			scrollBar.buttonHeight = 15;
			scrollBar.trackWidth  = 3;
			scrollBar.thumbWidth = 12;
			scrollBar.downSkin = createButtonSkin("downArrowSkin","downArrowOverSkin","downArrowDownSkin",null);
			scrollBar.upSkin = createButtonSkin("upArrowSkin","upArrowOverSkin","upArrowDownSkin",null);
			scrollBar.thumbSkin = createButtonSkin("thumbSkin","thumbOverSkin","thumbDownSkin","",new Rectangle(4,4,4,18));
			scrollBar.trackSkin = createSkin("trackSkin");
			return scrollBar;
		}

		public function get textScrollSkin():ScrollBarSkin{
			return scrollBarSkin;
		}

		public function get tabBarSkin():TabBarSkin{
			var tabSkin:TabBarSkin = new TabBarSkin();
			tabSkin.tabBtnFunc = getTabButtonSkin;
			tabSkin.soundFunc = playTabBarSound;
			return tabSkin;
		}
		
		public function getTabButtonSkin():ButtonSkin{
			var tabBtnSkin:ButtonSkin = createButtonSkin("tabSkin","tab_overSkin","tab_selectedSkin","tab_selectedSkin",new Rectangle(6,6,56,11));
			tabBtnSkin.selectedSkin = getUIBitmapData(LoadResource.UI_URL,"tab_overSkin"); 
			return tabBtnSkin;
		}
		
		public function get tabBarLeftSkin():TabBarSkin
		{
			var tabSkin:TabBarSkin = new TabBarSkin();
			tabSkin.tabBtnFunc = getTabLeftButtonSkin;
			tabSkin.soundFunc = playTabBarSound;
			return tabSkin;
		}
		
		public function getTabLeftButtonSkin():ButtonSkin
		{
			var btnSkin:ButtonSkin = new ButtonSkin();
			btnSkin.skin = getUIBitmapData(LoadResource.VIEWUI_URL,"tab_left_startSkin");
			btnSkin.overSkin = getUIBitmapData(LoadResource.VIEWUI_URL,"tab_left_overSkin");
			btnSkin.downSkin = getUIBitmapData(LoadResource.VIEWUI_URL,"tab_left_selectedSkin");
			btnSkin.rect = new Rectangle(12,11,61,16);
			btnSkin.selectedSkin = getUIBitmapData(LoadResource.VIEWUI_URL,"tab_left_selectedSkin");
			return btnSkin;
		}
		
		public function get comboBoxSkin():Skin{
			return createButtonSkin("comboxSkin","comboxOverSkin","comboxDownSkin",null,new Rectangle(20,7,57,7));
		}
		
		public function get sliderSkin():SliderSkin{
			var sliderSkin:SliderSkin = new SliderSkin();
			sliderSkin.backSkin = createSkin("sliderBack",new Rectangle(3,3,143,3));
			sliderSkin.handlerSkin = createButtonSkin("handlerSkin","handlerOver","handlerOver","",new Rectangle(3,3,9,9));
			return sliderSkin;
			return null;
		}
		
		public function get listSkin():ListSkin{
			var listSkin:ListSkin = new ListSkin();
			listSkin.overSkin = createSkin("overItem",new Rectangle(25,1,158,19));
			listSkin.selectedSkin = createSkin("selectedItem",new Rectangle(25,1,158,19));	
			listSkin.borderSkin=getSkin("inner_panel",LoadResource.VIEWUI_URL,new Rectangle(4,4,120,114));
			return listSkin;
		}
		
		public static function setPageRightButton(ui:UIComponent):void{
			ui.bgSkin = getButtonSkin("page_right_normal","page_right_over","page_right_down","page_right_normal",LoadResource.UI_URL);	
		}
		public static function setTeamButton(ui:UIComponent):void
		{
			ui.bgSkin = getButtonSkin("team_button","team_button_over","team_button","team_button",LoadResource.MAIN_URL);	
		}
		public static function setPageLeftButton(ui:UIComponent):void{
			ui.bgSkin = getButtonSkin("page_left_normal","page_left_over","page_left_down","page_left_normal",LoadResource.UI_URL);	
		}
		public function get textInputSkin():Skin{
			return createSkin("textSkin",new Rectangle(15,7,100,14));
		}
		
		public function get textAreaSkin():Skin{
			return createSkin("textSkin",new Rectangle(15,7,100,14));
		}		
		
		public function get panelSkin():PanelSkin{
			var panelSkin:PanelSkin = new PanelSkin();
			panelSkin.panelBgSkin = createSkin("panelBgSkin",new Rectangle(85,45,116,296));
			var closeSkin:ButtonSkin = createButtonSkin("close_skin","close_overSkin","close_downSkin",null,new Rectangle(0,0,0,0));
			var helpSkin:ButtonSkin = createButtonSkin("pro_skin","pro_overSkin","pro_down",null,new Rectangle(0,0,0,0));
			panelSkin.closeSkin = closeSkin;
			panelSkin.helpSkin = helpSkin;
			return panelSkin;
		}
		public function getSmallSpriteSkin(hasCloseButton:Boolean = true):PanelSkin{
			var smallSpriteSkin:PanelSkin = new PanelSkin();
			smallSpriteSkin.panelBgSkin = createSkin("smallSpriteBgSkin",new Rectangle(85,30,60,53));
			if(hasCloseButton){
				var closeSkin:ButtonSkin = createButtonSkin("close_skin","close_overSkin","close_downSkin",null,new Rectangle(0,0,0,0));
				smallSpriteSkin.closeSkin = closeSkin;
			}
			return smallSpriteSkin;
		}
		public function get alertPanelSkin():PanelSkin
		{
			var panelSkin:PanelSkin = new PanelSkin();
			panelSkin.panelBgSkin = createSkin("alertPanel",new Rectangle(107,57,69,60));
			var closeSkin:ButtonSkin = createButtonSkin("close_skin","close_overSkin","close_downSkin",null,new Rectangle(0,0,0,0));
			var helpSkin:ButtonSkin = createButtonSkin("pro_skin","pro_overSkin","pro_down",null,new Rectangle(0,0,0,0));
			panelSkin.closeSkin = closeSkin;
			panelSkin.helpSkin = helpSkin;
			return panelSkin;
		}
		
		public function get listItemSkin():Skin{
			//var skin:Skin = new Skin(getSource("listItemSkin"),new Rectangle(1,1,150,20));
			var skin:Skin = Style.getSkin("skinItem", LoadResource.UI_URL, new Rectangle(15, 4, 76, 12));
			return skin;
		}
		
		public function get numericStepperSkin():NumericStepperSkin{
			var numSkin:NumericStepperSkin = new NumericStepperSkin();
			var upSkin:ButtonSkin = createButtonSkin("numericStepper_Up","numericStepper_Up1","numericStepper_Up2","numericStepper_Up2");
			numSkin.upSkin = upSkin;
			var downSkin:ButtonSkin = createButtonSkin("numericStepper_Down","numericStepper_Down1","numericStepper_Down2","numericStepper_Down2");
			numSkin.downSkin = downSkin;
			var skin:Skin = createSkin("numericStepper_Text");
			numSkin.bgSkin = skin;
			return numSkin;
		}
		
		public function get tipSkin():Skin{
			return createSkin("ToolTip_Skin",new Rectangle(10,10,73,60));
		}
		public function get rightPopSkin():Skin{
			return createSkinViewUI("right_pop_bg");
		}
		/**
		 * 聊天底部选显卡样式 
		 */
		public static function getChatTabBarSkin():TabBarSkin{
			var tabSkin:TabBarSkin = new TabBarSkin();
			tabSkin.tabBtnFunc = getChatTabButtonSkin;
			tabSkin.soundFunc = playTabBarSound;
			return tabSkin;
		}
		 
		private static function getChatTabButtonSkin():ButtonSkin{
			var tabBtnSkin:ButtonSkin = getButtonSkin("ChatSkin","ChatoverSkin","ChatselectedSkin","ChatselectedSkin",LoadResource.MAIN_URL,new Rectangle(4,4,35,12));
			tabBtnSkin.selectedSkin = getUIBitmapData(LoadResource.MAIN_URL,"ChatselectedSkin"); 
			return tabBtnSkin;
		}
		
		
		/**
		 * 聊天底部选显卡样式 
		 */
		public static function getShopTabBarSkin():TabBarSkin{
			var tabSkin:TabBarSkin = new TabBarSkin();
			tabSkin.tabBtnFunc = getShopTabButtonSkin;
			return tabSkin;
		}
		
		private static function getShopTabButtonSkin():ButtonSkin{
			var tabBtnSkin:ButtonSkin = getButtonSkin("shopTabNavOn","shopTabNavOver","shopTabNavSelected","shopTabNavSelected",LoadResource.UI_URL,new Rectangle(15,10,52,17));
			tabBtnSkin.selectedSkin = getUIBitmapData(LoadResource.UI_URL,"shopTabNavSelected"); 
			return tabBtnSkin;
		}
		
		/**
		 * 任务追踪显卡样式 
		 * */
		public static function getTaskTabBarSkin():TabBarSkin{
			var tabSkin:TabBarSkin = new TabBarSkin();
			tabSkin.tabBtnFunc = getTaskTabButtonSkin;
			tabSkin.soundFunc = playTabBarSound;
			return tabSkin;
		}
		
		private static function getTaskTabButtonSkin():ButtonSkin{
			var tabBtnSkin:ButtonSkin = getButtonSkin("TaskBtn_upSkin","TaskBtn_upSkin","TaskBtn_downSkin","TaskBtn_downSkin",LoadResource.MAIN_URL,new Rectangle(5,5,51,11));
			tabBtnSkin.selectedSkin = getUIBitmapData(LoadResource.MAIN_URL,"TaskBtn_downSkin"); 
			return tabBtnSkin;
		}
		
		/**
		 * 聊天底部选显卡样式 
		 */
		public static function getBottomTabBarSkin():TabBarSkin{
			var tabSkin:TabBarSkin = new TabBarSkin();
			//tabSkin.tabBtnFunc = getBottomTabButtonSkin;
			tabSkin.soundFunc = playTabBarSound;
			return tabSkin;
		}
		
		private static function getBottomTabButtonSkin():ButtonSkin{
			var tabBtnSkin:ButtonSkin = getButtonSkin("DtabSkin","Dtab_overSkin","Dtab_selectedSkin","Dtab_selectedSkin",LoadResource.UI_URL,new Rectangle(4,2,37,18));
			tabBtnSkin.selectedSkin = getUIBitmapData(LoadResource.UI_URL,"Dtab_selectedSkin"); 
			return tabBtnSkin;
		}
		
		/**
		 *按背景名称加载，可设置是否需要关闭及帮助按钮 
		 * @param skname			背景名称
		 * @param hasCloseBtn		是否需要关闭按钮
		 * @param hasHelpBtn		是否需要帮助按钮
		 * @return 
		 * 
		 */			
		public function getSpriteSkin(skname:String, hasCloseBtn:Boolean ,hasHelpBtn:Boolean ,url:String=""):PanelSkin{
			var spriteSkin:PanelSkin = new PanelSkin();
			spriteSkin.panelBgSkin = createSkinViewUI(skname,new Rectangle(60,47,280,10),url);			//Rectangle表示可以拉升区域
			
			if(hasCloseBtn){
				var closeSkin:ButtonSkin = createButtonSkin("close_skin","close_overSkin","close_downSkin",null,new Rectangle(0,0,0,0));
				panelSkin.closeSkin = closeSkin;
			}
			if(hasHelpBtn)
			{
				var helpSkin:ButtonSkin = createButtonSkin("pro_skin","pro_overSkin","pro_down",null,new Rectangle(0,0,0,0));
				panelSkin.helpSkin = helpSkin;
			}
			return spriteSkin;
		}
		
//		public static function setRedBtnStyle(btn:Button):void{
//			btn.textColor = 0xffcc00;
//			btn.bgSkin = getButtonSkin("redBtn_skin","redBtn_overSkin","redBtn_downSkin","redBtn_disableSkin",LoadResource.UI_URL,new Rectangle(4,4,42,13));
//		}
		
		public static function setBlueBtnStyle(btn:Button):void
		{
			btn.textColor = 0xffcc00;
			btn.bgSkin = getButtonSkin("BlueBtn_skin","BlueBtn_overSkin","BlueBtn_downSkin",null,LoadResource.UI_URL,new Rectangle(4,4,42,13));
		}
		
		public static function setCashBtnStyle(btn:UIComponent):void
		{
//			btn.textColor = 0xffcc00;
			btn.bgSkin = getButtonSkin("cash_skin","cash_overSkin","cash_downSkin",null,LoadResource.POPUI_URL,new Rectangle(4,4,42,13));
		}
		
		public static function setExpBtnStyle(btn:UIComponent):void
		{
			
			btn.bgSkin = getButtonSkin("expicon_on","expicon_on","expicon_on",null,LoadResource.MAIN_URL,new Rectangle(4,4,42,13));
		}
		
		/**
		 * 潜水寻宝icon
		 * 
		 * */
		public static function setDivingIcon(btn:UIComponent):void
		{
			
			btn.bgSkin = getButtonSkin("divingIcon","divingIcon","divingIcon",null,LoadResource.MAIN_URL,new Rectangle(4,4,42,13));
		}
		/**
		 * 海低寻宝icon
		 * 
		 * */
		public static function setTreasureIcon(btn:UIComponent):void
		{
			
			btn.bgSkin = getButtonSkin("treasureIcon","treasureIcon","treasureIcon",null,LoadResource.MAIN_URL,new Rectangle(4,4,42,13));
		}
		
		
		public static function setAthleticsBtnStyle(btn:UIComponent):void
		{
			
			btn.bgSkin = getButtonSkin("athleticsIcon","athleticsIcon","athleticsIcon",null,LoadResource.MAIN_URL,new Rectangle(4,4,42,13));
		}
		
		public static function setFaceBookBtnStyle(btn:UIComponent):void
		{
			
			btn.bgSkin = getButtonSkin("facebook","facebook_rollover","facebook",null,LoadResource.MAIN_URL);
		}
		
		
		public static function setExpExitBtnStyle(btn:UIComponent):void
		{
			
			btn.bgSkin = getButtonSkin("tower_leave_btn","tower_leave_btn","tower_leave_btn",null,LoadResource.MAIN_URL,new Rectangle(4,4,42,13));
		}
		
		public static function setDailyBtnStyle(btn:UIComponent):void
		{
			
			btn.bgSkin = getButtonSkin("dailyicon_on","dailyicon_on","dailyicon_on",null,LoadResource.MAIN_URL,new Rectangle(4,4,42,13));
		}
		
//		public static function setSearchBtnStyle(btn:Button):void
//		{
//			btn.textColor = 0xffcc00;
//			btn.bgSkin = getButtonSkin("searchBtn_Skin","searchBtn_overSkin","searchBtn_Skin",null,LoadResource.UI_URL,new Rectangle(4,4,42,13));
//		}
		
		
		public static function setChatSendBtnStyle(btn:Button):void
		{
			btn.textColor = 0xffcc00;
			btn.bgSkin = getButtonSkin("sendSkin","sendOverSkin","sendDownSkin","sendDownSkin",LoadResource.MAIN_URL,new Rectangle(0,0,0,0));
		}
		
//		public static function setLoudSpeakBtnStyle(btn:UIComponent):void
//		{
//			btn.bgSkin = getInstance().createButtonSkin("loudspeakerSkin","loudspeakerOverSkin","loudspeakerDownSkin",null);	
//		}
		
		public static function setTaskDragStyle(btn:UIComponent):void
		{
			btn.bgSkin = getInstance().createButtonSkin("taskDrag","taskDragOver","taskDragDown",LoadResource.UI_URL,new Rectangle(0,0,0,0));	
		}
		
		public static function setHideBtnStyle(btn:Button):void{
			btn.bgSkin = getButtonSkin("DtabSkin","Dtab_selectedSkin","Dtab_selectedSkin",null,LoadResource.UI_URL,new Rectangle(4,4,23,14));	
		}
		
		/**
		 *  内置的背景框1
		 * @param ui
		 * 
		 */		
		public static function setInnerSpriteStyle(ui:UIComponent):void
		{
			ui.bgSkin = getSkin("inner_panel",LoadResource.VIEWUI_URL,new Rectangle(10,10,109,103));
		}
		/**
		 * 内置的背景框2 
		 * @param ui
		 * 
		 */		
		public static function setRightSpriteStyle(ui:UIComponent):void{
			ui.bgSkin=getSkin("right_panel",LoadResource.VIEWUI_URL,new Rectangle(10,10,146,105));
		}
		
		/**
		 * 栏目头部
		 * 
		 * */
		public static function setHeadDecBar(ui:UIComponent):void{
			ui.bgSkin=getSkin("headDecBar",LoadResource.MAIN_URL,new Rectangle(60,0,451,23));
		}
		
		
		public static function setShopBlueStyle(ui:UIComponent):void{
			ui.bgSkin=getSkin("shopbulebg",LoadResource.VIEWUI_URL,new Rectangle(10,10,146,105));
		}
		
		/**
		 * 蓝色底 
		 * @param ui
		 * 
		 */		
		public static function setBlueSpriteStyle(ui:UIComponent):void
		{
			ui.bgSkin=Style.getSkin("bluebg", LoadResource.VIEWUI_URL, new Rectangle(10, 10, 60, 45));
		}
		/**
		 * 内置的小背景框 
		 * @param ui
		 * 
		 */		
		public static function setSmallSpriteStyle(ui:UIComponent):void
		{
			ui.bgSkin=getSkin("small_sprite",LoadResource.UI_URL,new Rectangle(4,4,128,112));
		}
		
		public static function setScrollEnableStyle(btn:UIComponent):void{
			btn.bgSkin = getButtonSkin("leftHide","leftHide","leftHide",null,LoadResource.UI_URL);
		}
		
		public static function setClearStyle(btn:UIComponent):void{
			btn.bgSkin = getButtonSkin("clear","clearOver","clear",null,LoadResource.VIEWUI_URL);
		}
		
		public static function setVipButtonStyle(btn:UIComponent):void
		{
			btn.bgSkin = getButtonSkin("vip_skin","vip_skin_over","vip_skin_down",null,LoadResource.UI_URL);
		}
		public static function setLeftHookMinButtonStyle(btn:UIComponent):void{
			btn.bgSkin = getButtonSkin("left_hook_min_btn","left_hook_min_over_btn","left_hook_min_down_btn",null,LoadResource.VIEWUI_URL);
		}
		public static function setRightHookMinButtonStyle(btn:UIComponent):void{
			btn.bgSkin = getButtonSkin("right_hook_min_btn","right_hook_min_over_btn","right_hook_min_down_btn",null,LoadResource.VIEWUI_URL);
		}
		public static function setaddBtnStyle(btn:Button):void{
			btn.bgSkin = getButtonSkin("addBtn_upSkin","addBtn_overSkin","addBtn_downSkin",null,LoadResource.UI_URL);	
		}
		public static function setSubtractBtnStyle(btn:Button):void{
			btn.bgSkin = getButtonSkin("subtract_button","subtract_over_button","subtract_down_button",null,LoadResource.UI_URL);	
		}
		public static function setNoivceBtnStyle(btn:Button):void{
			btn.bgSkin = getButtonSkin("noviceBtn_skin","noviceBtn_over","noviceBtn_down",null,LoadResource.UI_URL);	
		}
		public static function setHeadBarStyle(ui:UIComponent):void{
			ui.bgSkin = getSkin("head_bar",LoadResource.VIEWUI_URL,new Rectangle(52,5,25,11));	
		}
		public static function setDeepRedBtnStyle(btn:Button):void
		{
			var deepRedSkin:ButtonSkin = getButtonSkin("button_skin","button_overSkin","button_downSkin","button_downSkin",LoadResource.UI_URL,new Rectangle(15,10,33,5));
			deepRedSkin.soundFunc = playButtonSound;
			btn.bgSkin = deepRedSkin;	
		}
		
//		public static function setLoginLeftBtnStyle(btn:Button):void{
//			btn.bgSkin = getButtonSkin("left_skin","left_overSkin","left_overSkin","left_disableSkin",LoadResource.LOGINUI_URL);
//		}
		
		public static function setHeadPreBtnStyle(btn:Button):void
		{
			var bgskin:ButtonSkin;
			//bgskin = getButtonSkin("jiantouSkin","jiantouOverSkin","jiantouDownSkin","jiantouDownSkin",LoadResource.UI_URL);
			bgskin.scaleX = -1;
			btn.bgSkin = bgskin;
		}
		
		public static function setHeadNextBtnStyle(btn:Button):void
		{
			//btn.bgSkin = getButtonSkin("jiantouSkin","jiantouOverSkin","jiantouDownSkin","jiantouDownSkin",LoadResource.UI_URL);
		}
		
		public function getZoomLessBtnSkin():Skin
		{
			return getButtonSkin("zoomLessBtn_skin","zoomLessBtn_skin","zoomLessBtn_skin",null,LoadResource.MAIN_URL);
		}
		
		public function getZoomAddBtnSkin():Skin
		{
			return getButtonSkin("zoomAddBtn_skin","zoomAddBtn_skin","zoomAddBtn_skin",null,LoadResource.MAIN_URL);
		}
		
//		public static function setLoginRightBtnStyle(btn:Button):void{
//			btn.bgSkin = getButtonSkin("right_skin","right_overSkin","right_overSkin","right_disableSkin",LoadResource.LOGINUI_URL)
//		}
		
		public static function setLoginBtnStyle(btn:Button):void
		{
			btn.textColor = 0xffff00;
			btn.bgSkin = getButtonSkin("jin_1","jin_2","jin_3","jin_1",LoadResource.SELECT_ROLE_URL)
		}
		
		public static function setDeleteBtnStyle(btn:Button):void
		{
			//btn.textColor = 0xffff00;
			btn.bgSkin = getButtonSkin("deleteRole","deleteRoeOver","deleteRoleOut","deleteRole",LoadResource.SELECT_ROLE_URL)
		}
		
		public static function setCreateBtnStyle(btn:Button):void
		{
			//btn.textColor = 0xffff00;
			btn.bgSkin = getButtonSkin("createRole","createRoleOver","createRoleOut","createRole",LoadResource.SELECT_ROLE_URL)
		}
		public static function setDailyAnswerBackGroudImagSkin(ui:UIComponent):void{
			ui.bgSkin = getSkin("dailyAnswerBg",LoadResource.VIEWUI_URL,new Rectangle(10,10,524,278));
		}
		
//		public static function setCountryBtnStyle(btn:Button):void{
//			var url:String = LoadResource.LOGINUI_URL;
//			var buttonSkin:ButtonSkin = getButtonSkin("country_overSkin","country_selectedSkin","country_selectedSkin",null,url);
//			buttonSkin.selectedSkin = getUIBitmapData(url,"country_selectedSkin");
//			btn.bgSkin = buttonSkin;
//			
//		}	
	    
//		public static function setLoginCheckBoxStyle(checkbox:CheckBox):void
//		{
//			var url:String =  LoadResource.LOGINUI_URL;
//			
//			var skin:CheckBoxSkin = new CheckBoxSkin();
//			skin.selectedSkin = new Skin(getUIBitmapData(url,"check_selectedSkin"));
//			skin.unSelectedSkin = new Skin(getUIBitmapData(url,"check_skin"));
//			checkbox.checkBoxSkin = skin;
//			
//		}
		
//		public static function setCountryTGBtnStyle(tgBtn:ToggleButton):void
//		{
//			var url:String =  LoadResource.LOGINUI_URL;
//			var buttonSkin:ButtonSkin = getButtonSkin("country_skin","country_overSkin","country_selectedSkin",null,url);
//			buttonSkin.selectedSkin = getUIBitmapData(url,"country_selectedSkin");
//			tgBtn.bgSkin = buttonSkin;
//		}
			
		public static function setBorderSkin(ui:UIComponent):void{
			//ui.bgSkin = getSkin("border",LoadResource.VIEWUI_URL,new Rectangle(10,10,246,102));
			ui.bgSkin = getSkin("border",LoadResource.VIEWUI_URL,new Rectangle(10,25,246,116));
		}
		
		public static function setFriendBorderSkin(ui:UIComponent):void{
			//ui.bgSkin = getSkin("border",LoadResource.VIEWUI_URL,new Rectangle(10,10,246,102));
			ui.bgSkin = getSkin("friendBg",LoadResource.VIEWUI_URL,new Rectangle(10,10,154,113));
		}
		
		public static function setFirendTaskLineBgSkin(ui:UIComponent):void
		{
			ui.bgSkin = getSkin("friendTaskLineBg",LoadResource.VIEWUI_URL,new Rectangle(10,10,269,2));
		}
		
		public static function setBorder3Skin(ui:UIComponent):void{
			ui.bgSkin = getSkin("border1",LoadResource.VIEWUI_URL,new Rectangle(10,10,246,102));
		}
		
		public static function setBorder1Skin(ui:UIComponent):void{
			ui.bgSkin = getSkin("jinengBg",LoadResource.VIEWUI_URL,new Rectangle(10,5,418,15));
		}
		
		public static function setRoundBorder(ui:UIComponent):void{
			ui.bgSkin = getSkin("roundBorder",LoadResource.VIEWUI_URL,new Rectangle(20,20,240,86));	
		}
		
		public static function setRectBorder(ui:UIComponent):void{
			ui.bgSkin = getSkin("rectBorder",LoadResource.VIEWUI_URL,new Rectangle(10,10,35,160));	
		}
		
		public static function setSaleBorder(ui:UIComponent):void{
			ui.bgSkin = getSkin("payBg",LoadResource.VIEWUI_URL,new Rectangle(10,6,255,21));	
		}
		
		public static function setDesBorder(ui:UIComponent):void{
			ui.bgSkin = getSkin("desBg",LoadResource.VIEWUI_URL,new Rectangle(10,6,255,21));	
		}
		
//		public function get alertSkin():PanelSkin{
//			var panelSkin:PanelSkin = new PanelSkin();
//			panelSkin.panelBgSkin = createSkin("smallSpriteBgSkin",new Rectangle(81,23,63,56));
//			var closeSkin:ButtonSkin = createButtonSkin("close_skin","close_overSkin","close_downSkin",null,new Rectangle(0,0,0,0));
//			panelSkin.closeSkin = closeSkin;
//			return panelSkin;
//		}
		
		public static function playTabBarSound():void{
//			MusicManager.playSound(MusicManager.TABBAR);
		}
		
		public static function playButtonSound():void{
//			MusicManager.playSound(MusicManager.BUTTON);
		}
	}
}